﻿using Inovout.Gui.Wpf.ViewModel;
using Inovout.Organizations.Model;
using System.Windows.Input;
using Inovout.Gui.Wpf;
using Inovout.Organizations.Business;

namespace Inovout.Organizations.Gui.Wpf.ViewModels
{
    public class EmployeeViewModel:ModelViewModel<Employee>
    {
        protected Employee Employee
        {
            get 
            {
                if (ViewData == null)
                {
                    return new Employee { Name="Huay"};
                }

                return (ViewData.Model as Employee)??new Employee(); 
            }
        }
        public EmployeeViewModel()
        {
        }
        private ICommand saveCommand;
        public ICommand SaveCommand
        {
            get 
            {
                //if (saveCommand == null)
                //{
                    saveCommand = new ViewModelCommand(OrganizationFunctions.SaveEmployee, this, "Employee");
                //}
                return saveCommand;
            }
        }

        public string Name
        {
            get { return Employee.Name; }
            set 
            {
                ONPropertyChanged<string>("Name", Employee.Name, value);
                Employee.Name = value;
            }
        }
    }
}
